#!/usr/bin/env python
# coding:utf-8

print '----------------------------------------------------------------------------------------------------'
class A(object):
    attr_1 = 1
    def __init__(self):
        self.attr_1 = 11
        self.attr_2 = 2
        pass

a = A()
print a.attr_2
# 2
print a.attr_1
# 11
print A.attr_1
# 1
# print A.attr_2
# AttributeError: type object 'A' has no attribute 'attr_2'

print '----------------------------------------------------------------------------------------------------'
def triangle():
    l = [1]
    while True:
        yield l
        l = [sum(i) for i in zip([0] + l, l + [0])]

c = 0
for n in triangle():
    c += 1
    if c < 10:
        print n
    else:
        break
print '----------------------------------------------------------------------------------------------------'
s = 'I am a student'
ss = ' '.join(map(lambda x: x[::-1], s.split()))
print s
print ss
print '----------------------------------------------------------------------------------------------------'
g = (i for i in range(5))
print type(g)
# <type 'generator'>
print '----------------------------------------------------------------------------------------------------'
l = [1, -2, 3, -4, 5, -6]
ll = sorted(l, key=lambda x: (x < 0, abs(x)))
print ll
# [1, 3, 5, -2, -4, -6]
print '----------------------------------------------------------------------------------------------------'
l = range(10)
print l
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

print l[:]  # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print l[::]  # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print l[::-1]  # [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

print l[0:9]  # [0, 1, 2, 3, 4, 5, 6, 7, 8]
print l[0:-1]  # [0, 1, 2, 3, 4, 5, 6, 7, 8]

print l[0:-1:-1]  # []
print l[0:-2:-1]  # []

print l[0:9:-1]  # []
print l[9:0:-1]  # [9, 8, 7, 6, 5, 4, 3, 2, 1]
print '----------------------------------------------------------------------------------------------------'
